﻿@using Website.CRUDServices
@using Website.Models.Styling
@using Location = Website.Models.Domain.Location
@model Website.Models.ViewModels.ListView<ProjectMeeting>
@{
    this.ViewBag.Title = "Netværk";
    this.Layout = "~/Views/_Shared/_Layout.cshtml";
    var ProjectTypes = this.ViewData["ProjectTypes"] as List<ProjectType>;
    var Locations = this.ViewData["Locations"] as List<Location>;
}

<div class="float-right smallMarginBottom">
    <input type="button" onclick="@string.Format("location.href = '{0}';", this.Url.Action("NewProject"))" value="Opret ny" class="" />
</div>
<table class="tableView">
    <tr>
        @foreach (TableViewHeaderItem item in this.Model.Header.Items)
        {
            <td>
                @Html.Partial("~/Views/_Shared/TableViewHeader.cshtml", item)
            </td>
        }
        <td></td>
    </tr>
    @if (this.Model != null)
    {
        foreach (ProjectMeeting meeting in this.Model.List)
        {
            List<Location> locs = Locations.Where(x => x.ID == meeting.LocationID).ToList();
            Location location = locs.Count() > 0 ? Locations[0] : null;
        <tr>
            <td>@string.Format("{0:dd-MM-yyyy}", meeting.Date)</td>
            <td>
                @if (location != null)
                {
                    @location.Name
                }
            </td>
            <td>@meeting.Name</td>
            <td>@meeting.Status.Description</td>
            <td>
                @if (meeting.Status.Type != Guid.Empty)
                {
                    List<ProjectType> types = ProjectTypes.Where(x => x.ID == meeting.Status.Type).ToList();
                    if (types != null && types.Count() > 0)
                    {
                    @Html.Raw(string.Format("({0}) {1}", types[0].IsResearchAndDevelopment ? "R&D" : "Ikke R&D", types[0].Name))
                    }
                }
            </td>
            <td>
                @meeting.Status.PatentName
            </td>
            <td>
                <a href="@Url.Action("UpdateProject", new { @Id = meeting.ID })">
                    <img src="@Url.Content("~/Content/ButtonIcons/tool_blue.png")" alt="Link"/></a>
            </td>
            <td><a href="@Url.Action("UpdateProject", new { @Id = meeting.ID })">
                <img src="@Url.Content("~/Content/ButtonIcons/tool_blue.png")" alt="Link"/></a></td>
        </tr>
        }
    }
    <tr>
        @Html.Partial("~/Views/_Shared/PagingArrows.cshtml", new PagingArrows { Action = "Index", TotalAmountOfColumns = 7, CurrentSkip = this.Model.Skip, CurrentTake = this.Model.Take, CurrentTotalRowCount = this.Model.TotalRows })
    </tr>
</table>
